﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using core;

namespace comix
{
    public class Series:SiteItemSingle,ISiteItemMember
    {
        protected string m_name;
        protected int m_pub_id;
        private Publisher m_publisher;
        public Publisher Publisher
        {
            get
            {
                if (m_publisher == null && m_pub_id>0)
                {
                    m_publisher = new Publisher();
                    m_publisher.Id = m_pub_id;
                    m_publisher.FillItem();
                }
                return m_publisher;
            }
        }

        protected int m_cat_id;
        private Categories m_category;
        public Categories Category
        {
            get
            {
                if (m_category == null && m_cat_id>0 )
                {
                    m_category = new Categories();
                    m_category.Id = m_cat_id;
                    m_category.FillItem();
                }
                return m_category;
            }
        }

        public Series()
        {
            m_com.CommandText = "SELECT * FROM Series WHERE ser_id = @ser_id";
        }

        public override void DoFill(System.Data.SqlClient.SqlDataReader rdr)
        {
            Id = (int)rdr["ser_id"];
            m_name = (string)rdr["ser_name"];
            m_pub_id = (int)rdr["ser_pub_id"];
            m_cat_id = (int)rdr["ser_cat_id"];
        }

        public override void SetSelectParameters()
        {
            m_com.Parameters.Clear();
            m_com.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ser_id", Id));
        }

        #region ISiteItemMember Members

        public void FillMember(System.Data.SqlClient.SqlDataReader rdr)
        {
            Id = (int)rdr["ser_id"];
            m_name = (string)rdr["ser_name"];
            m_pub_id = (int)rdr["ser_pub_id"];
            m_cat_id = (int)rdr["ser_cat_id"];
        }

        #endregion
    }
}
